import { ContentType } from '../../constants';
import { useContext } from 'react';
import { observer } from "mobx-react-lite";
import { MySdkStoreContext } from '../../context';
import Rtc from './Rtc';
import StrongReminder from './StrongReminder';
import NormalMessage from './NormalMessage';


// 根据新消息类型，展示不同的组件
export default observer(function(props) {
  const mySdkStore = useContext(MySdkStoreContext);
  const { visible, msgType, ...restProps } = mySdkStore.newMessageTopBarProps;

  if(!visible) {
    return <></>;
  }
  if(mySdkStore.mockConfig.userId === restProps.from.userId) {
    return <></>;
  }
  
  switch(msgType) {
    case ContentType.Rtc:
      return <Rtc {...restProps} />;
    case ContentType.StrongReminder:
      return <StrongReminder {...restProps} />;
    default:
      return <NormalMessage {...restProps} />;
  }
})